<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <!--如果是IE 就以标准渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <!-- 视窗——————响应式布局 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

    <!--当前页面的三要素-->
    <title>运维系统</title>
    <meta name="description" content="聚能优电" />
    <meta http-equiv="keywords" content="聚能优电" />
    <script type="text/javascript" src="../../js/verify.js"></script>
    <script type="text/javascript" src="../../js/common/commonfuntion.js"></script>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="../../css/uploadImg.css" />
    <link rel="stylesheet" type="text/css" href="../../css/orderdetail.css" />
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../../css/mobiscroll.custom.min.css" />
    <link rel="stylesheet" href="https://at.alicdn.com/t/font_1805932_ysrcp4y0uy9.css">

    <style>
        html,body{
            height:100%;
        }

        .orderdetail_screen .tit_con .con_position .bottompart li{
            height:0.6rem;
        }
        .orderdetail_screen .tit_con .con_position .bottompart li .lileft{
            font-family: MicrosoftYaHei;
            font-size: 14px;
            color: #7F94B2;
            letter-spacing: 0.88px;
        }
        .orderdetail_screen .tit_con .con_position .bottompart li .liright{
            font-family: MicrosoftYaHei;
            font-size: 14px;
            color: #C3D4EA;
            letter-spacing: 0.88px;
        }
        .statewrap{
            margin-top:20px;
        }
        .statewrap .showstate{
            height:30px;
            line-height:30px;
            padding:0 20px;
            display:inline-block;
            border: 1px solid rgba(1,103,255,0.3);
            border-radius: 31px;
            font-family: SourceHanSansCN-Regular;
            font-size: 14px;
            color: #0167FF;
            letter-spacing: 1.75px;
        }

        /* 展示问题照片 */
        #showimg img{
            width: 80px;
            height: 80px;
            margin: 7px;
        }

        #showfile span{
            display: inline-block;
            padding: 0.1rem 0.2rem;
            font-family: MicrosoftYaHei;
            font-size: 0.28rem;
            color: #0167FF;
            letter-spacing: 0.88px;
            background: rgba(35, 62, 106,0.44);
            border-radius: 2px;
            margin-bottom: 0.2rem;
            margin-right: 0.2rem;
        }

        /* 上传问题照片 */
        .main{
            width:100%;
        }

        .main .upload-content h3{
            font-size: 0.28rem;
            color: #7F94B2;
            letter-spacing: 0;
            font-weight: bold;
        }

        .main .upload-content .content-img .file{
            width:60px;
            height:60px;
            line-height:60px;
        }
        .main .upload-content .content-img .file input{
            width:60px;
            height:60px;
        }
        .main .upload-content .content-img .content-img-list .content-img-list-item{
            width:60px;
            height:60px;
            line-height:60px;
        }
        .main .upload-content .content-img .content-img-list .content-img-list-item >img{
            width:100%;
            height:100%;
            display:block;
            overflow:hidden;
        }

        .main .upload-content .content-img-list-item div{
            line-height:60px;
        }



    </style>
</head>

<body>
    <div id="container" class="orderdetail">
        <div class="orderdetail_01">
            <!--主屏内容-->
            <div class="orderdetail_screen">
                <div class="m_title">
                    <a href="JavaScript:history.go(-1);" class="back">
                        <img src="../../images/back.svg" alt="">
                    </a>
                    <span class="tit" id="showname"></span>
                </div>

                <div class="tit_con">
                    <img src="../../images/orderbg.svg" alt="">
                    <div class="con_position">
                        <div class="toppart">
                            <div class="pleft floatpart" id="ordername">
                            </div>
                            <div class="pright floatpart" style="color:#34EE83;font-weight:bold;">
                                进行中
                            </div>
                        </div>
                        <ul class="bottompart">
                            <li>
                                <span class="lileft">填报人：</span><span class="liright" id="tbr"></span>
                            </li>
                            
                            <li>
                                <span class="lileft">执行人：</span><span class="liright" id="zxr"></span>
                            </li>
                            <li>
                                <span class="lileft">联系方式：</span><span class="liright" id="tel"></span>
                            </li>
                            <li>
                                <span class="lileft">创建时间：</span><span class="liright" id="createtime">2019-10-11 16:51:00</span>
                            </li>
                        </ul>
                    </div>

                </div>
                
                <!-- 问题描述 -->
                <div class="gj_tit title">问题描述</div>
                <div class="cljg hdnr_con" style="width:98%;margin-top:20px;color: #7F94B2;border:1px solid rgb(27, 49, 80);padding:5px 0;text-indent:5px;" id="questioncon">
                </div>

                <!-- 紧急程度 -->
                <div class="statewrap">
                    <span class="showstate" id="showstate"></span>
                </div>

                <!-- 问题照片 -->
                <div id="showimg_wrap">
                    <div class="gj_tit title">问题照片</div>
                    <div id="showimg" style="margin-top:10px;"></div>
                </div>

                <!-- 附件 -->
                <div id="showfile_wrap">
                    <div class="gj_tit title">附件</div>
                    <div id="showfile" style="margin-top:10px;">
                    </div>
                </div>

                
                <div id="fujian_wrap">
                    <!-- <ul class="gj_con" style="margin-top:0.3rem;">
                        <li onclick="window.location.href='./orderreceipt.html'">
                            <span class="lileft">处理回单1</span><span class="liright"><img src="../../images/arrowsr.svg"
                                    alt=""></span>
                        </li>
                        <li onclick="window.location.href='./orderreceipt.html'">
                            <span class="lileft">处理回单2</span><span class="liright"><img src="../../images/arrowsr.svg"
                                    alt=""></span>
                        </li>
                    </ul> -->

                </div>

                <div id="shoueditor">
                    <div class="hdnr_tit title">回单内容</div>
                    <div class="cljg hdnr_con">
                        <div class="cljg_tit tit">处理结果</div>
                        <textarea name="" id="dealresult" placeholder="请输入处理结果"></textarea>
                    </div>

                    <div class="clcs hdnr_con">
                        <div class="clcs_tit tit">处理措施</div>
                        <textarea name="" id="dealway" placeholder="请输入处理措施"></textarea>
                    </div>


                    <div class="main" id="sctp" style="margin-top:20px;">
                        <div class="upload-content">
                            <h3>上传图片</h3>
                            <div class="content-img">
                                <ul class="content-img-list" id="img_wrap"></ul>
                                <div class="file">
                                    <i class="gcl gcladd"></i>
                                    <input type="file" name="file" accept="image/*" id="upload" multiple="multiple" />
                                </div>
                            </div>
                            <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                                <div class="modal-dialog modal-lg" role="document">
                                    <div class="modal-content">
                
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 上传文件 -->
                    <div class="hdnr_tit title">上传附件</div>
                    <div class="layui-upload" style="margin-top:0.4rem;">
                        <div class="layui-upload-list">
                            <table class="layui-table">
                                <thead>
                                    <tr>
                                        <th>文件名</th>
                                        <th>大小</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="demoList"></tbody>
                            </table>
                        </div>

                        <button type="button" class="layui-btn layui-btn-normal" id="testList">选择多文件</button>
                        <button type="button" class="layui-btn" id="testListAction" style="font-size:0.24rem;">开始上传</button>

                    </div>

                    <div class="hdnr_tit title">工单处理</div>
                    <div class="orderdeal">
                        <input type="radio" name="deal" id="to_next" value="0" /><label for="to_next">指派下一个处理人</label>
                        <input type="radio" name="deal" id="sub_end" value="1" /><label for="sub_end">提交工单完结</label>
                    </div>
                    <div id="dealer" style="display:none;">
                        <select name="" id="selectclr"></select>
                    </div>
                    <div id="ender" style="display:none;color:#7F94B2;">
                        <div>
                            <span>完结工单审核人:</span>
                            <select name="" id="selectend"></select>
                        </div>
                    </div>

                    <div class="wrap_btn">
                        <div class="sub_btn" style="margin-top:1rem;" id="sub_btn">提 交</div>
                    </div>
                </div>


            </div>
        </div>
    </div>


    <script>
        (function (win, doc) {
            var docEl = doc.documentElement || document.body; //获取HTML标签

            var container = doc.getElementById("container"); //container元素
            //判断是移动端设备还是PC,移动 就采用'orientationchange',横竖屏事件，PC端就采用onresize，窗口改变时间
            var resize =
                "onorientationchange" in win ? "orientationchange" : "resize";

            function rem() {
                docEl.style.fontSize = 100 * (container.clientWidth / 750) + "px";
            }

            //监听'DOMContent事件:DOM加载完成执行,如果DOMContent事件，那么执行rem函数
            doc.addEventListener("DOMContentLoaded", rem, false);

            //win下监听resize事件,如果resize事件，那么执行rem函数
            win.addEventListener(resize, rem, false);
        })(window, document);
    </script>
    <!-- js -->
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/mobiscroll.custom.min.js"></script>
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script type="text/javascript" src="../../js/zooming.js"></script>
    <script>
        $(document).ready(function () {
            

            const getinfo = async () => {

                var projectid = GetQueryString('projectid');
                var orderID = GetQueryString('orderID');
                var projectNameCN = GetQueryString('projectname');
                var orderName = GetQueryString('orderName');

                $("#showname").html();
                $("#showname").html(projectNameCN);

                $("#ordername").html();
                $("#ordername").html(orderName);


                var stepnum;
                var resresult;
                var ordercontant;
                var dealcreattime;
                var orderzxr;
                // 获取填报人信息
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "http://112.74.169.99:21021/api/services/app/DevOpsService/GetAfterSaleOrder?id=" + orderID,
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("Accept",
                            "application/json, text/javascript, */*; q=0.01"
                        );
                        xhr.setRequestHeader("Authorization", accessToken);
                        xhr.setRequestHeader('.AspNetCore.Culture',
                            'zh-Hans');
                    },
                    success: function (res) {
                        console.log(res);
                        if(res.success){

                            stepnum = Number(res.result.stepnum) + 1;
                            resresult = res.result;
                            // 填报人
                            $("#tbr").html( res.result.creatername );
                            
                            

                            // 联系方式
                            $("#tel").html(res.result.telePhone);

                            // 创建时间
                            var thecreattime = res.result.creattime;
                            dealcreattime = thecreattime.substring(0,10) + " " + thecreattime.substring(11,19);
                            $("#createtime").html(dealcreattime);

                            // 问题描述
                            $("#questioncon").html(res.result.problemDescription);

                            // 紧急程度
                            var degreeOfUrgency;
                            if(res.result.degreeOfUrgency == '1'){
                                degreeOfUrgency = '非常紧急';
                            }else if(res.result.degreeOfUrgency == '2'){
                                degreeOfUrgency = '紧急';
                            }else if(res.result.degreeOfUrgency == '3'){
                                degreeOfUrgency = '不紧急';
                            }
                            $("#showstate").html('');
                            $("#showstate").html(degreeOfUrgency);


                            // json格式内容
                            ordercontant = JSON.parse( res.result.ordercontant );
                            console.log(ordercontant);

                            // 执行人
                            orderzxr = res.result.executorname;
                            $("#zxr").html( orderzxr );
                            console.log(orderzxr);
                            
                            if(ordercontant["contantcheck"]){
                                if( orderzxr == window.localStorage.getItem("name")){
                                    $("#shoueditor").css('display','none');
                                }
                            }else{
                                if( orderzxr != window.localStorage.getItem("name")){
                                    $("#shoueditor").css('display','none');
                                }
                            }
                            

                            window.localStorage.setItem('ordercontant',res.result.ordercontant);
                            
                            // 问题照片遍历
                            if(ordercontant["contant00"].uploadimg.length>0){
                                $("#showimg").html( imgeach(ordercontant["contant00"].uploadimg) );
                                
                            }else{
                                $("#showimg_wrap").css('display','none');
                            }

                            // 附件遍历
                            if(ordercontant["contant00"].uploadfile.length>0){
                                $("#showfile").html( eachfile(ordercontant["contant00"].uploadfile) );

                            }else{
                                $("#showfile_wrap").css('display','none');
                            }

                            if(stepnum > 1){
                                $("#fujian_wrap").append( eachhuidan(stepnum) );
                            }

                        }

                    },
                    error: function (err) {
                        console.log("请求失败");
                    }
                });

                // 上传图片功能
                var imgFile = []; //文件流
                var imgSrc = []; //图片路径
                var imgBlob = []; //图片Blob
                // 鼠标经过显示删除按钮
                $('.content-img-list').on('mouseover', '.content-img-list-item', function() {
                    $(this).children('div').removeClass('hide');
                });
                // 鼠标离开隐藏删除按钮
                $('.content-img-list').on('mouseleave', '.content-img-list-item', function() {
                    $(this).children('div').addClass('hide');
                });

                $('#upload').on('change', function(e) {
                    var fileList = this.files;
                    var imgBox = '.content-img-list';
                    async function upload(file){
                        for(var j = 0; j < file.length; j++){
                            const img = await readImg( file[j] );
                            const blob = await compressImg( img, file[j].type, 1000, 600 );
                            
                            if (blob.size > 1024 * 1024 * 1) { //1MB
                                return alert("上传图片不能超过1MB");
                            };

                            if (blob.type != 'image/png' && blob.type != 'image/jpeg' && blob.type != 'image/gif') {
                                return alert("图片上传格式不正确");
                            }

                            imgBlob.push(blob);
                            imgFile.push(file[j]); //文件流

                            var imgSrcI = getObjectURL(file[j]);
                            imgSrc.push(imgSrcI); //图片路径
                            
                        }
                        addNewContent(imgBox);
                    }

                    upload( fileList ).catch(e => console.log(e));
                });


                // 单个图片删除
                $(".content-img-list").on("click", '.content-img-list-item a .gcllajitong', function() {
                    var index = $(this).parent().parent().parent().index();
                    imgSrc.splice(index, 1);
                    imgFile.splice(index, 1);
                    var boxId = ".content-img-list";
                    addNewContent(boxId);
                });


                //图片展示
                function addNewContent(obj) {
                    $(obj).html("");
                    for (var a = 0; a < imgSrc.length; a++) {
                        var oldBox = $(obj).html();
                        $(obj).html(oldBox + '<li class="content-img-list-item"><img src="' + imgSrc[a] + '" alt="">' +
                            '<div class="hide"><a index="' + a + '" class="delete-btn"><i class="gcl gcllajitong"></i></a>');
                    }
                }

                //建立可存取到file的url
                function getObjectURL(file) {
                    var url = null;
                    if (window.createObjectURL != undefined) { // basic
                        url = window.createObjectURL(file);
                    } else if (window.URL != undefined) { // mozilla(firefox)
                        url = window.URL.createObjectURL(file);
                    } else if (window.webkitURL != undefined) { // webkit or chrome
                        url = window.webkitURL.createObjectURL(file);
                    }
                    return url;
                }

                // 压缩前将file转换成img对象
                function readImg(file) {
                    return new Promise((resolve, reject) => {
                        const img = new Image()
                        const reader = new FileReader()
                        reader.onload = function(e) {
                            img.src = e.target.result
                        }
                        reader.onerror = function(e) {
                            reject(e)
                        }
                        reader.readAsDataURL(file)
                        img.onload = function() {
                            resolve(img)
                        }
                    })
                }

                function compressImg(img, type, mx, mh) {
                    return new Promise((resolve, reject) => {
                        const canvas = document.createElement('canvas')
                        const context = canvas.getContext('2d')
                        const { width: originWidth, height: originHeight } = img
                        // 最大尺寸限制
                        const maxWidth = mx
                        const maxHeight = mh
                        // 目标尺寸
                        let targetWidth = originWidth
                        let targetHeight = originHeight
                        if (originWidth > maxWidth || originHeight > maxHeight) {
                        if (originWidth / originHeight > 1) {
                            // 宽图片
                            targetWidth = maxWidth
                            targetHeight = Math.round(maxWidth * (originHeight / originWidth))
                        } else {
                            // 高图片
                            targetHeight = maxHeight
                            targetWidth = Math.round(maxHeight * (originWidth / originHeight))
                        }
                        }
                        canvas.width = targetWidth
                        canvas.height = targetHeight
                        context.clearRect(0, 0, targetWidth, targetHeight)
                        // 图片绘制
                        context.drawImage(img, 0, 0, targetWidth, targetHeight)
                        canvas.toBlob(function(blob) {
                            resolve(blob)
                        }, type || 'image/png')
                    })
                }


                // 图片
                function imgeach(uploadimg){
                    var str = '';
                    for(var i=0;i<uploadimg.length;i++){
                        str += `<img src="http://` + uploadimg[i] + `" alt="" data-action="zoom">`;
                    }
                    return str;
                }
                
                // 附件
                function eachfile(uplodfile){
                    var str = '';
                    for(var k=0;k<uplodfile.length;k++){
                        str += `<span onclick="window.location.href='http://112.74.169.99:21021/Temp/Upload/` + uplodfile[k][0] + `'">` + uplodfile[k][0] + `</span>`;
                    }
                    return str;
                }
                
                
                
                // 处理回单
                function eachhuidan(stepnum){
                    console.log();
                    var stepnum = stepnum - 1;
                    var str = '';
                    str += `<ul class="gj_con" style="margin-top:0.3rem;">`;
                    for(var m=0;m<stepnum;m++){
                        str += `<li onclick="window.location.href='./huidan_show.html?contantnum=contant` + (m+1) + `&huidanname=处理回单` + (m+1) + `'">
                            <span class="lileft">处理回单`+ (m+1) + `</span>
                            <span class="liright"><img src="../../images/arrowsr.svg" alt=""></span>
                            </li>`;
                    }
                    str += `</ul>`;
                    return str;
                }

                // 上传附件
                var uploadfile = [];
                layui.use('upload', function(){
                    var $ = layui.jquery
                    ,upload = layui.upload;

                    var demoListView = $('#demoList')
                    ,uploadListIns = upload.render({
                        elem: '#testList'
                        ,url: 'http://112.74.169.99:21021/api/FileUpload/GatherImageUploadPost' //改成您自己的上传接口
                        ,accept: 'file'
                        ,multiple: true
                        ,auto: false
                        ,bindAction: '#testListAction'
                        ,choose: function(obj){
                            var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                            //读取本地文件
                            obj.preview(function(index, file, result){
                            var tr = $(['<tr id="upload-'+ index +'">'
                                ,'<td>'+ file.name +'</td>'
                                ,'<td>'+ (file.size/1024).toFixed(1) +'kb</td>'
                                ,'<td>等待上传</td>'
                                ,'<td>'
                                    ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                                    ,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                                    ,'</td>'
                                ,'</tr>'].join(''));

                            //单个重传
                            tr.find('.demo-reload').on('click', function(){
                                obj.upload(index, file);
                            });

                            //删除
                            tr.find('.demo-delete').on('click', function(){
                                delete files[index]; //删除对应的文件
                                tr.remove();
                                uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                            });

                            demoListView.append(tr);
                            });
                        }
                        ,done: function(res, index, upload){
                            if(res.result.fileurl){
                                var filename = [];
                                for(var x in res.result){
                                    filename.push(res.result[x]);
                                }
                                uploadfile.push(filename);
                        
                                var tr = demoListView.find('tr#upload-'+ index)
                                ,tds = tr.children();
                                tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                                tds.eq(3).html(''); //清空操作
                            }
                        }
                        ,error: function(index, upload){
                            var tr = demoListView.find('tr#upload-'+ index)
                            ,tds = tr.children();
                            tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                            tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
                        }
                    });
                });


                // 工单处理---单选框选中事件
                $('input:radio[name="deal"]').change(function () {
                    if ($("#to_next").is(":checked")) {
                        $("#dealer").show();
                        $("#ender").hide();
                        // 获取指派处理人的名单
                        $.ajax({
                            type: "GET",
                            dataType: "json",
                            url: "http://112.74.169.99:21021/api/services/app/DevOpsService/GetUserInfoList",
                            beforeSend: function (xhr) {
                                xhr.setRequestHeader("Accept",
                                    "application/json, text/javascript, */*; q=0.01"
                                );
                                xhr.setRequestHeader("Authorization", accessToken);
                                xhr.setRequestHeader('.AspNetCore.Culture',
                                    'zh-Hans');
                            },
                            success: function (res) {
                                if(res.success){
                                    console.log(orderzxr);
                                    $("#selectclr").html(' ');
                                    $("#selectclr").append( eachclr(res.result,orderzxr) );
                                }
                                console.log(res);
                            },
                            error: function (err) {
                                console.log("请求失败");
                            }
                        });

                    }
                    if ($("#sub_end").is(":checked")) {
                        $("#ender").show();
                        $("#dealer").hide();

                        // 获取审核处理人的名单
                        $.ajax({
                            type: "GET",
                            dataType: "json",
                            url: "http://112.74.169.99:21021/api/services/app/DevOpsService/GetUserInfoList",
                            beforeSend: function (xhr) {
                                xhr.setRequestHeader("Accept",
                                    "application/json, text/javascript, */*; q=0.01"
                                );
                                xhr.setRequestHeader("Authorization", accessToken);
                                xhr.setRequestHeader('.AspNetCore.Culture',
                                    'zh-Hans');
                            },
                            success: function (res) {
                                if(res.success){
                                    console.log(orderzxr);
                                    $("#selectend").html(' ');
                                    $("#selectend").append( eachclr(res.result,orderzxr) );
                                }
                                console.log(res);
                            },
                            error: function (err) {
                                console.log("请求失败");
                            }
                        });

                    }
                })

                function eachclr(lilength,orderzxr){
                    var str = ``;
                    for(var j=0;j < lilength.length;j++){
                        if( lilength[j].userName != orderzxr ){
                            str += `<option id="` + lilength[j].userID + `" userName="` + lilength[j].userName + `">` + lilength[j].userName + `</option>`;
                        }
                    }
                    return str;
                }
                
                
                
                // 提交
                $("#sub_btn").click(function(){
                    var uploadimg = [];
                    console.log(imgFile);
                    console.log(uploadfile);
                    const subshunxu = async () => {

                        if(imgFile.length > 0){
                            for(let i = 0; i < imgFile.length; i++){
                                var formFile = '';
                                formFile = new FormData();
                                formFile.append('file', imgBlob[i], imgFile[i].name);

                                await $.ajax({
                                    url: 'http://112.74.169.99:21021/api/FileUpload/GatherImageUploadPost',
                                    type: 'post',
                                    data: formFile,
                                    async: true,
                                    cache: false,
                                    contentType: false,
                                    processData: false,
                                    success: function(res){
                                        console.log('图片上传成功');
                                        uploadimg.push(res.result.fileurl);
                                    },
                                    error: function(res){
                                        console.log(res);
                                    }
                                });
                            }
                        }

                        resresult.stepnum = stepnum;// 更新执行次数

                        var itemcon = {};
                        itemcon.uploadimg = uploadimg;
                        itemcon.uploadfile = uploadfile;
                        itemcon.dealresult = $("#dealresult").val(); //回单内容 处理结果
                        itemcon.dealway = $("#dealway").val();//回单内容 处理措施
                        itemcon.dealtime = getDate();
                        if( $("#to_next").is(":checked") ){
                            var executorid = $("#selectclr").find("option:selected").attr("id"); //下一个执行人id
                            var executorname = $("#selectclr").find("option:selected").attr("userName");//下一个执行人名称
                            resresult.executorid = Number(executorid);
                            resresult.executorname = executorname;
                            resresult.orderstate = Number($("#to_next").val()); // 未完成工单状态
                            itemcon.dealname = orderzxr;
                            itemcon.nextdealid = executorid;
                            itemcon.nextdealname = executorname;
                        }
                        if( $("#sub_end").is(":checked") ){
                            var executorid = $("#selectend").find("option:selected").attr("id"); //审核人id
                            var executorname = $("#selectend").find("option:selected").attr("userName");//审核人名称
                            resresult.executorid = Number(executorid);
                            resresult.executorname = executorname;
                            resresult.orderstate = $("#sub_end").val(); // 提交工单完结
                            resresult.completetime =  getDate();//完成时间
                            itemcon.dealname = orderzxr;
                            itemcon.nextdealid = executorid;
                            itemcon.nextdealname = executorname;
                        }
                        
                        var itemname = "contant" + stepnum;
                        ordercontant[itemname] = itemcon;

                        ordercontant = JSON.stringify(ordercontant);
                        resresult.ordercontant = ordercontant;
                        resresult.executortime =  getDate();//执行时间
                        resresult.assignortime =  getDate();//指派时间
                        resresult.creattime = dealcreattime; //创建时间
                        resresult.assignorname = window.localStorage.getItem("name");//指派人姓名
                        resresult.assignor = Number(window.localStorage.getItem("id"));//指派人id
                        

                        console.log(resresult.ordercontant);
                        console.log(resresult);
                        resresult = JSON.stringify(resresult);

                        $.ajax({
                            url: "http://112.74.169.99:21021/api/services/app/DevOpsService/CreatAfterSaleOrderByUpdate",
                            data: resresult,
                            type: "post",
                            dataType: "json",
                            beforeSend: function (xhr) {
                                xhr.setRequestHeader("Content-Type", "application/json");
                                xhr.setRequestHeader(
                                    "Accept",
                                    "application/json, text/plain, */*"
                                );
                            },
                            success: function (res) {
                                console.log(res);
                                // return;
                                window.location.href = "../project_aftersale.html?projectid=" + projectid + "&projectname=" +projectNameCN;
                            
                            },
                            error: function (err) {
                                console.log("请求失败");
                            }
                        });
                    }

                    subshunxu();


                });


                // 获取当前时间
                function getDate(){
                    var myDate = new Date();
                    //获取当前年
                    var year = myDate.getFullYear();
                    //获取当前月
                    var month = myDate.getMonth() + 1;
                    //获取当前日
                    var date = myDate.getDate();
                    var h = myDate.getHours(); //获取当前小时数(0-23)
                    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
                    var s = myDate.getSeconds();
                    //获取当前时间
                    var now = year + '-' + conver(month) + "-" + conver(date) + " " + conver(h) + ':' + conver(m) + ":" + conver(s);
                    return now;
                }

                //日期时间处理
                function conver(s) {
                    return s < 10 ? '0' + s : s;
                }


            }
            getinfo();

        });
    </script>

</body>

</html>